Skip to content

Fix crash at thread exit#591

Open
zhengyu123 wants to merge 9 commits into
mainfrom
zgu/thread_exit_cleanup
Open

Fix crash at thread exit#591
zhengyu123 wants to merge 9 commits into
mainfrom
zgu/thread_exit_cleanup

Conversation

@zhengyu123

@zhengyu123 zhengyu123 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?:
Fixed crashes during thread exit cleanup.

Motivation:
Improve stability.

Additional Notes:
On glibc, pthread_exit and pthread_cancel trigger _Unwind_ForcedUnwind from the dynamic libgcc_s.so.1. When the forced unwind walks a frame belonging to code built with -static-libgcc (both libjavaProfiler.so and the gtest binaries), it calls the static __gxx_personality_v0. The two libgcc versions have incompatible _Unwind_Context layouts. If the personality function finds a cleanup or handler action and calls _Unwind_SetGR, the cold/error path aborts.

Two patterns create LSDA actions that trigger _Unwind_SetGR:

  • C++ RAII objects with destructors (struct Cleanup, __pthread_cleanup_class from pthread_cleanup_push in C++ mode, SigGuard)
  • try/catch handler frames (catch (abi::__forced_unwind&))

How to test the change?:
Three failed tests now passed.

  • forced_unwind_ut
  • thread_teardown_safety_ut
  • DynamicNativeThread

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.
  • JIRA: PROF-15046

Unsure? Have a question? Request a review!

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jun 10, 2026

Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/java-profiler | gtest-tsan-arm64   View in Datadog   GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5492dd2 | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #27370600787 | Commit: 37e9a81 | Duration: 13m 34s (longest job)

All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - - -
8-ibm - - -
8-j9 - -
8-librca - -
8-orcl - - -
11 - - -
11-j9 - -
11-librca - -
17 - -
17-graal - -
17-j9 - -
17-librca - -
21 - -
21-graal - -
21-librca - -
25 - -
25-graal - -
25-librca - -

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-06-11 19:19:28 UTC

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jun 10, 2026

Copy link
Copy Markdown

BitsAI couldn’t fix CI

BitsAI couldn’t produce a safe fix for this CI failure. Open the Datadog session to inspect the attempt or continue from there.

Progress

🟢 Investigated · 🔴 Fix failed · ⚪ Validate · ⚪ Ready


Commit: bcbbfcb

View session in Datadog

@zhengyu123 zhengyu123 marked this pull request as ready for review June 10, 2026 21:07
@zhengyu123 zhengyu123 requested a review from a team as a code owner June 10, 2026 21:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bcbbfcb817

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0e50af7e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ddprof-lib/src/test/cpp/forced_unwind_ut.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/thread_teardown_safety_ut.cpp

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6fe3f44dc3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ddprof-lib/src/test/cpp/stress_callTraceStorage.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp
Comment thread ddprof-lib/src/test/cpp/thread_teardown_safety_ut.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/thread_teardown_safety_ut.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/forced_unwind_ut.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/stress_callTraceStorage.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/thread_teardown_safety_ut.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/thread_teardown_safety_ut.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/thread_teardown_safety_ut.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/forced_unwind_ut.cpp
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp
Comment thread ddprof-lib/src/test/cpp/thread_teardown_safety_ut.cpp Outdated
Comment thread ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp Outdated
Comment thread ddprof-lib/src/test/cpp/forced_unwind_ut.cpp
Comment thread ddprof-lib/src/test/cpp/forced_unwind_ut.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants